#ifndef PLAYERCONTROLS_H
#define PLAYERCONTROLS_H

#include <QWidget>
#include <QMediaPlayer>

class QAbstractButton;
class QAbstractSlider;
class QComboBox;

class PlayerControls : public QWidget
{
    Q_OBJECT
public:
    PlayerControls(QWidget *parent = 0);
    QMediaPlayer::State state() const;
    int volume() const;
    bool isMuted() const;
    qreal playbackRate() const;

signals:
    void play(); //播放触发信号
    void pause(); //暂停触发信号
    void stop(); //停止~
    void next(); //下一首
    void previous(); //上一首
    void changedVolume(int volume);
    void changeMutting(bool muting);
    void changeRate(qreal rate);

public slots:
    void setState(QMediaPlayer::State state); //设置状态
    void setVolume(int volume); //控制音量
    void setMuted(bool muted);
    void setPlaybackRate(float rate);

private slots:
    void playClicked();
    void muteClicked();
    void updateRate();

private:
    QMediaPlayer::State playerState;
    bool playerMuted;
    QAbstractButton *playButton;
    QAbstractButton *stopButton;
    QAbstractButton *nextButton;
    QAbstractButton *previousButton;
    QAbstractButton *muteButton;
    QAbstractSlider *volumeSlider;
    QComboBox *rateBox;

};

#endif // PLAYERCONTROLS_H
